package org.aeon.heroicsagatextedition.round.product;

import org.aeon.heroicsagatextedition.commands.AttackCommand;
import org.aeon.heroicsagatextedition.commands.AttackInvoker;
import org.aeon.heroicsagatextedition.commands.Command;
import org.aeon.heroicsagatextedition.constants.CommonlyConstants;
import org.aeon.heroicsagatextedition.role.product.RoleUnit;

import java.util.Deque;
import java.util.Iterator;

/**
 * @projectName: HeroicSagaTextEdition
 * @package: org.aeon.heroicsagatextedition.round
 * @className: MonsterRound
 * @author: MissingAeon
 * @date: 2023/12/22 15:13
 * @description: 怪物回合
 */
public class MonsterRound extends Round {

    public MonsterRound(RoleUnit role) {
        super(role);
    }

    @Override
    public void roundResponse() {
        System.out.println(role.getName() + "，开始回合行动：");
        action();
        super.roundResponse();
    }

    /**
     * 回合开始时的行动
     */
    private void action() {
        Deque<RoleUnit> campPlayers = super.campPlayers(CommonlyConstants.RIGHTEOUS);

        // int targetNumber = ScannerUtil.scanInt();
        Iterator<RoleUnit> iterator = campPlayers.iterator();
        // for (int i = 0; i < targetNumber - 1; i++) {
        //     iterator.next();
        // }
        RoleUnit target = iterator.next();
        Command command = AttackCommand.newGoals(target, role.getAttack());

        AttackInvoker attackInvoker = new AttackInvoker();
        attackInvoker.setCommand(command);
        attackInvoker.attack();
    }
}
